const Koa = require('koa')
const app = new Koa()
const static =require('koa-static');
const path=require('path');
const Router =require('koa-router');
const router=new Router();
const {
    historyApiFallback
} = require('koa2-connect-history-api-fallback')
const koaServerHttpProxy = require('koa-server-http-proxy')

router.get("/api/get",async (ctx,next)=>{
	ctx.body={
		code:0,
		data:[1,2,3,4]
	};
});
// app.use(async (ctx, next) => {
// 	ctx.response.redirect(`http://${ctx.host}${ctx.path}`)
// })

//设置代理,config使用nacos配置读取
// config.proxy.forEach(proxy => {
// 	app.use(koaServerHttpProxy(proxy.route, proxy.option))
// })
//支持path刷新访问
app.use(historyApiFallback())
app.use(static(path.join(__dirname,"./dist")))
app.use(router.routes());
app.listen(3000, () => {
	console.log('app started at http://localhost:3000/')
})
